package timing.ukulele.minio.utils;

/**
 *
 * 后缀名与ContentType对照表
 * 该工具类中保存了常见资源后缀名所对应的ContentType类型，便于返回资源数据时声明其ContentType格式。详见public String getContentType(String suffix)方法。
 */
public class ContentTypeUtil {

	private static final String SEPARATOR = ".";

	/**
	 *
	 * 通过后缀名获取对应的ContentType
	 * 由文件的后缀名得到相应的ContentType以便浏览器识别该资源。该方法将返回ContentType类型字符串，型如“application/octet-stream”。
	 * @author 青阳龙野(kohgylw)
	 * @param suffix java.lang.String 资源的后缀名，必须以“.”开头，例如“.jpg”
	 * @return java.lang.String 传入后缀所对应的ContentType，若无对应类型则统一返回“application/octet-stream”（二进制流）
	 */
	public static String getContentType(String suffix) {

		String _suffix = suffix;

		if(!suffix.contains(SEPARATOR)){
			_suffix = SEPARATOR + suffix;
		}

        return switch (_suffix) {
            case ".hta" -> "application/hta";
            case ".tdf" -> "application/x-tdf";
            case ".eml", ".mht", ".mhtml", ".nws" -> "message/rfc822";
            case ".vdx", ".vsd", ".vss", ".vst", ".vsw", ".vsx", ".vtx" -> "application/vnd.visio";
            case ".csi" -> "application/x-csi";
            case ".plt" -> "application/x-plt";
            case ".906" -> "application/x-906";
            case ".rnx" -> "application/vnd.rn-realplayer";
            case ".xlw" -> "application/x-xlw";
            case ".mp2" -> "audio/mp2";
            case ".pl" -> "application/x-perl";
            case ".mp3" -> "audio/mp3";
            case ".mp1" -> "audio/mp1";
            case ".wav" -> "audio/wav";
            case ".rp" -> "image/vnd.rn-realpix";
            case ".hmr" -> "application/x-hmr";
            case ".top" -> "drawing/x-top";
            case ".avi" -> "video/avi";
            case ".pdf" -> "application/pdf";
            case ".htt" -> "text/webviewhtml";
            case ".torrent" -> "application/x-bittorrent";
            case ".dcx" -> "application/x-dcx";
            case ".biz", ".cml", ".dcd", ".dtd", ".ent", ".fo", ".math", ".mml", ".mtx", ".rdf", ".spp", ".svg", ".tld",
                 ".tsd", ".vml", ".vxml", ".wsdl", ".xdr", ".xml", ".xq", ".xql", ".xquery", ".xsd", ".xsl", ".xslt" ->
                    "text/xml";
            case ".sam" -> "application/x-sam";
            case ".wk3" -> "application/x-wk3";
            case ".cdf" -> "application/x-netcdf";
            case ".uls" -> "text/iuls";
            case ".p12", ".pfx" -> "application/x-pkcs12";
            case ".aif", ".aifc", ".aiff" -> "audio/aiff";
            case ".wk4" -> "application/x-wk4";
            case ".lar" -> "application/x-laplayer-reg";
            case ".sat" -> "application/x-sat";
            case ".htm", ".html", ".htx", ".jsp", ".plg", ".stm", ".xhtml" -> "text/html";
            case ".ltr" -> "application/x-ltr";
            case ".wpl" -> "application/vnd.ms-wpl";
            case ".anv" -> "application/x-anv";
            case ".p10" -> "application/pkcs10";
            case ".gl2" -> "application/x-gl2";
            case ".css" -> "text/css";
            case ".vpg" -> "application/x-vpeg005";
            case ".dwg" -> "application/x-dwg";
            case ".slk" -> "drawing/x-slk";
            case ".wma" -> "audio/x-ms-wma";
            case ".sty" -> "application/x-sty";
            case ".wm" -> "video/x-ms-wm";
            case ".cut" -> "application/x-cut";
            case ".a11" -> "application/x-a11";
            case ".sdw" -> "application/x-sdw";
            case ".dgn" -> "application/x-dgn";
            case ".cel" -> "application/x-cel";
            case ".dxb" -> "application/x-dxb";
            case ".tga" -> "application/x-tga";
            case ".dxf" -> "application/x-dxf";
            case ".mil" -> "application/x-mil";
            case ".wmf" -> "application/x-wmf";
            case ".latex" -> "application/x-latex";
            case ".mdb" -> "application/msaccess";
            case ".wks" -> "application/x-wks";
            case ".wkq" -> "application/x-wkq";
            case ".xap" -> "application/x-silverlight-app";
            case ".tg4" -> "application/x-tg4";
            case ".mp2v", ".mpv2" -> "video/mpeg";
            case ".ras" -> "application/x-ras";
            case ".pko" -> "application/vnd.ms-pki.pko";
            case ".m1v", ".m2v", ".mpe", ".mps" -> "video/x-mpeg";
            case ".wsc" -> "text/scriptlet";
            case ".rsml" -> "application/vnd.rn-rsml";
            case ".cdr" -> "application/x-cdr";
            case ".001" -> "application/x-001";
            case ".la1" -> "audio/x-liquid-file";
            case ".asp" -> "text/asp";
            case ".301" -> "application/x-301";
            case ".etd" -> "application/x-ebx";
            case ".gif" -> "image/gif";
            case ".mns" -> "audio/x-musicnet-stream";
            case ".dwf" -> "Model/vnd.dwf";
            case ".asa" -> "text/asa";
            case ".bmp" -> "application/x-bmp";
            case "." -> "application/x-";
            case ".323" -> "text/h323";
            case ".fdf" -> "application/vnd.fdf";
            case ".pic" -> "application/x-pic";
            case ".cot" -> "application/x-cot";
            case ".sdp" -> "application/sdp";
            case ".pgl" -> "application/x-pgl";
            case ".doc", ".dot", ".rtf", ".wiz" -> "application/msword";
            case ".net" -> "image/pnetvue";
            case ".m3u" -> "audio/mpegurl";
            case ".js", ".ls", ".mocha" -> "application/x-javascript";
            case ".rv" -> "video/vnd.rn-realvideo";
            case ".sst" -> "application/vnd.ms-pki.certstore";
            case ".wvx" -> "video/x-ms-wvx";
            case ".rle" -> "application/x-rle";
            case ".rlc" -> "application/x-rlc";
            case ".rat" -> "application/rat-file";
            case ".vda" -> "application/x-vda";
            case ".mxp" -> "application/x-mmxp";
            case ".r3t" -> "text/vnd.rn-realtext3d";
            case ".lbm" -> "application/x-lbm";
            case ".p7r" -> "application/x-pkcs7-certreqresp";
            case ".wbmp" -> "image/vnd.wap.wbmp";
            case ".dbx" -> "application/x-dbx";
            case ".p7c", ".p7m" -> "application/pkcs7-mime";
            case ".img" -> "application/x-img";
            case ".bot" -> "application/x-bot";
            case ".ws", ".ws2" -> "application/x-ws";
            case ".ram", ".rmm" -> "audio/x-pn-realaudio";
            case ".sol", ".sor", ".txt" -> "text/plain";
            case ".p7b", ".spc" -> "application/x-pkcs7-certificates";
            case ".png" -> "image/png";
            case ".crl" -> "application/pkix-crl";
            case ".cg4", ".g4", ".ig4" -> "application/x-g4";
            case ".m4e", ".mp4" -> "video/mpeg4";
            case ".movie" -> "video/x-sgi-movie";
            case ".mpeg", ".mpg", ".mpv" -> "video/mpg";
            case ".ipa" -> "application/vnd.iphone";
            case ".cal" -> "application/x-cals";
            case ".drw" -> "application/x-drw";
            case ".dbf" -> "application/x-dbf";
            case ".pls", ".xpl" -> "audio/scpls";
            case ".dbm" -> "application/x-dbm";
            case ".ssm" -> "application/streamingmedia";
            case ".gbr" -> "application/x-gbr";
            case ".907" -> "drawing/907";
            case ".mpga" -> "audio/rn-mpeg";
            case ".mfp", ".swf" -> "application/x-shockwave-flash";
            case ".hpg" -> "application/x-hpgl";
            case ".rmvb" -> "application/vnd.rn-realmedia-vbr";
            case ".rmf" -> "application/vnd.adobe.rmf";
            case ".class", ".java" -> "java/*";
            case ".mi" -> "application/x-mi";
            case ".xls" -> "application/vnd.ms-excel";
            case ".pci" -> "application/x-pci";
            case ".man" -> "application/x-troff-man";
            case ".pcl" -> "application/x-pcl";
            case ".mpd", ".mpp", ".mpt", ".mpw", ".mpx" -> "application/vnd.ms-project";
            case ".xfdf" -> "application/vnd.adobe.xfdf";
            case ".pcx" -> "application/x-pcx";
            case ".edn" -> "application/vnd.adobe.edn";
            case ".ptn" -> "application/x-ptn";
            case ".iff" -> "application/x-iff";
            case ".wri" -> "application/x-wri";
            case ".smi", ".smil" -> "application/smil";
            case ".wrk" -> "application/x-wrk";
            case ".sis", ".sisx" -> "application/vnd.symbian.install";
            case ".ai", ".eps", ".ps" -> "application/postscript";
            case ".htc" -> "text/x-component";
            case ".cmp" -> "application/x-cmp";
            case ".p7s" -> "application/pkcs7-signature";
            case ".xwd" -> "application/x-xwd";
            case ".mac" -> "application/x-mac";
            case ".cmx" -> "application/x-cmx";
            case ".out" -> "application/x-out";
            case ".hgl" -> "application/x-hgl";
            case ".iii" -> "application/x-iphone";
            case ".au", ".snd" -> "audio/basic";
            case ".smk" -> "application/x-smk";
            case ".igs" -> "application/x-igs";
            case ".ins", ".isp" -> "application/x-internet-signup";
            case ".epi" -> "application/x-epi";
            case ".rt" -> "text/vnd.rn-realtext";
            case ".pot", ".ppa", ".pps", ".ppt", ".pwz" -> "application/vnd.ms-powerpoint";
            case ".nrf" -> "application/x-nrf";
            case ".frm" -> "application/x-frm";
            case ".rmx" -> "application/vnd.rn-realsystem-rmx";
            case ".hqx" -> "application/mac-binhex40";
            case ".mpa" -> "video/x-mpg";
            case ".sld" -> "application/x-sld";
            case ".tif", ".tiff" -> "image/tiff";
            case ".sit" -> "application/x-stuffit";
            case ".slb" -> "application/x-slb";
            case ".mnd" -> "audio/x-musicnet-download";
            case ".wmd" -> "application/x-ms-wmd";
            case ".fif" -> "application/fractals";
            case ".dib" -> "application/x-dib";
            case ".wp6" -> "application/x-wp6";
            case ".lmsff" -> "audio/x-la-lms";
            case ".cat" -> "application/vnd.ms-pki.seccat";
            case ".wmz" -> "application/x-ms-wmz";
            case ".cgm" -> "application/x-cgm";
            case ".icb" -> "application/x-icb";
            case ".rm" -> "application/vnd.rn-realmedia";
            case ".rmj" -> "application/vnd.rn-realsystem-rmj";
            case ".pdx" -> "application/vnd.adobe.pdx";
            case ".red" -> "application/x-red";
            case ".xdp" -> "application/vnd.adobe.xdp";
            case ".wax" -> "audio/x-ms-wax";
            case ".IVF" -> "video/x-ivf";
            case ".x_b" -> "application/x-x_b";
            case ".asf", ".asx" -> "video/x-ms-asf";
            case ".mid", ".midi", ".rmi" -> "audio/mid";
            case ".c4t" -> "application/x-c4t";
            case ".xfd" -> "application/vnd.adobe.xfd";
            case ".wmv" -> "video/x-ms-wmv";
            case ".hpl" -> "application/x-hpl";
            case ".gp4" -> "application/x-gp4";
            case ".wmx" -> "video/x-ms-wmx";
            case ".wml" -> "text/vnd.wap.wml";
            case ".cer", ".crt", ".der" -> "application/x-x509-ca-cert";
            case ".ppm" -> "application/x-ppm";
            case ".x_t" -> "application/x-x_t";
            case ".ra" -> "audio/vnd.rn-realaudio";
            case ".rmp" -> "application/vnd.rn-rn_music_package";
            case ".pr" -> "application/x-pr";
            case ".rec" -> "application/vnd.rn-recording";
            case ".wr1" -> "application/x-wr1";
            case ".dll", ".exe" -> "application/x-msdownload";
            case ".jfif", ".jpe", ".jpeg", ".jpg" -> "image/jpeg";
            case ".c90" -> "application/x-c90";
            case ".ico" -> "image/x-icon";
            case ".rjs" -> "application/vnd.rn-realsystem-rjs";
            case ".awf" -> "application/vnd.adobe.workflow";
            case ".emf" -> "application/x-emf";
            case ".rjt" -> "application/vnd.rn-realsystem-rjt";
            case ".wb2" -> "application/x-wb2";
            case ".wb1" -> "application/x-wb1";
            case ".wb3" -> "application/x-wb3";
            case ".cit" -> "application/x-cit";
            case ".rgb" -> "application/x-rgb";
            case ".rms" -> "application/vnd.rn-realmedia-secure";
            case ".stl" -> "application/vnd.ms-pki.stl";
            case ".prf" -> "application/pics-rules";
            case ".uin" -> "application/x-icq";
            case ".wq1" -> "application/x-wq1";
            case ".acp" -> "audio/x-mei-aac";
            case ".hrf" -> "application/x-hrf";
            case ".rpm" -> "audio/x-pn-realaudio-plugin";
            case ".vcf" -> "text/x-vcard";
            case ".lavs" -> "audio/x-liquid-secure";
            case ".pc5" -> "application/x-pc5";
            case ".apk" -> "application/vnd.android.package-archive";
            case ".odc" -> "text/x-ms-odc";
            case ".spl" -> "application/futuresplash";
            case ".wpd" -> "application/x-wpd";
            case ".wpg" -> "application/x-wpg";
            case ".prn" -> "application/x-prn";
            case ".prt" -> "application/x-prt";
            case ".fax" -> "image/fax";
            default -> "application/octet-stream";
        };
	}

}
